package easy;

public class Solution_1385 {

    public int findTheDistanceValue(int[] arr1, int[] arr2, int d) {
        boolean[] flags = new boolean[2201];
        for (int num : arr2) {
            int a = num + 1100;
            for (int i = a - d; i <= a + d; i++) {
                flags[i] = true;
            }
        }
        int count = 0;
        for (int num : arr1) {
            if (!flags[num + 1100]) {
                count++;
            }

        }
        return count;
    }

    public static void main(String[] args) {
        Solution_1385 model = new Solution_1385();
        System.out.println(model.findTheDistanceValue(new int[]{4, 5, 8}, new int[]{10, 9, 1, 8}, 2));
        System.out.println(model.findTheDistanceValue(new int[]{1, 4, 2, 3}, new int[]{-4, -3, 6, 10, 20, 30}, 3));
        System.out.println(model.findTheDistanceValue(new int[]{2, 1, 100, 3}, new int[]{-5, -2, 10, -3, 7}, 6));
    }
}
